package com.test.reggieadmin.model.fragment.tcgl;

import com.test.reggieadmin.base.BaseObserver;
import com.test.reggieadmin.base.BasePresenter;
import com.test.reggieadmin.bean.BaseBean;
import com.test.reggieadmin.bean.SetmealPageBean;

import java.util.Map;

public class TcglPrensenter extends BasePresenter<TcglView> {
    public TcglPrensenter(TcglView baseView) {
        super(baseView);
    }

    /**
     * 套餐信息分页查询
     *
     * @param page
     * @param pageSize
     * @param name
     * @param type
     */
    public void setmealPage(int page, int pageSize, String name, int type) {
        addDisposable(apiServer.setmealPage(page, pageSize, name), new BaseObserver<SetmealPageBean>() {
            @Override
            public void onSuccess(SetmealPageBean bean) {
                baseView.setmealPageSuccess(bean, type);
            }

            @Override
            public void onError(String msg) {
                baseView.setmealPageError(msg);
            }
        });
    }

    /**
     * 删除套餐
     *
     * @param ids
     */
    public void deleteSetmeal(String ids) {
        addDisposable(apiServer.deleteSetmeal(ids), new BaseObserver<BaseBean>() {
            @Override
            public void onSuccess(BaseBean bean) {
                baseView.deleteSetmealSuccess(bean);
            }

            @Override
            public void onError(String msg) {
                baseView.onError(msg);
            }
        });
    }

    /**
     * 修改套餐
     *
     * @param map
     */
    public void updateSetmeal(Map<String, Object> map) {
        addDisposable(apiServer.updateSetmeal(map), new BaseObserver<BaseBean>() {
            @Override
            public void onSuccess(BaseBean bean) {
                baseView.updateSetmealSuccess(bean);
            }

            @Override
            public void onError(String msg) {
                baseView.onError(msg);
            }
        });
    }
}
